export class Chapter {
  resources: Resource[]
  roles: Role[]

  currentIndex = 0;
  currentFrameId = 0;

  constructor(public chapter: LDChapter.Chapter) {
    this.resources = Object.values(this.chapter.resources).map(resource => new Resource(resource))

    this.roles = Object.values(this.chapter.roles).map(role => new Role(role))
  }

  get Frames() {
    return Object.values(this.chapter.frames.map)
  }

  get currentFrame() {
    return this.chapter.frames.map[this.currentFrameId]
  }

  getFrame(frameId: number) {
    return this.chapter.frames.map[frameId]
  }

  getResource(resourceId: number) {
    return this.chapter.resources[resourceId]
  }

  getRole(roleId: number) {
    return this.chapter.roles[roleId]
  }

  next(frameId = this.currentFrameId) {
    return this.getFrame(frameId).nextId
  }
}

export class Resource {
  constructor(public resource: LDChapter.Resource) {

  }
}

export class Role {
  constructor(public role: LDChapter.Role) {

  }
}
